class AuthResponse {
  final String name;
  final String token;
  final int expires;

  AuthResponse({
    required this.name,
    required this.token,
    required this.expires,
  });

  // Convert to JSON map
  Map<String, dynamic> toJson() => {
    'name': name,
    'token': token,
    'expires': expires,
  };

  // Factory constructor from JSON
  factory AuthResponse.fromJson(Map<String, dynamic> json) => AuthResponse(
    name: json['name'] as String,
    token: json['token'] as String,
    expires: json['expires'] as int,
  );

  @override
  String toString() {
    return 'AuthResponse{name: $name, token: $token, expires: $expires}';
  }
}

// Optional: JWT Claims class
class JwtClaims {
  final int id;
  final int pid;
  final int deptId;
  final int roleId;
  final String roleKey;
  final String username;
  final String realName;
  final String avatar;
  final String email;
  final String mobile;
  final String app;
  final String loginAt;
  final dynamic device;

  JwtClaims({
    required this.id,
    required this.pid,
    required this.deptId,
    required this.roleId,
    required this.roleKey,
    required this.username,
    required this.realName,
    required this.avatar,
    required this.email,
    required this.mobile,
    required this.app,
    required this.loginAt,
    required this.device,
  });

  factory JwtClaims.fromJson(Map<String, dynamic> json) => JwtClaims(
    id: json['id'] as int,
    pid: json['pid'] as int,
    deptId: json['deptId'] as int,
    roleId: json['roleId'] as int,
    roleKey: json['roleKey'] as String,
    username: json['username'] as String,
    realName: json['realName'] as String,
    avatar: json['avatar'] as String,
    email: json['email'] as String,
    mobile: json['mobile'] as String,
    app: json['app'] as String,
    loginAt: json['loginAt'] as String,
    device: json['device'],
  );

  @override
  String toString() {
    return 'JwtClaims{id: $id, username: $username, roleKey: $roleKey}';
  }
}